package com.atlantis.apps.notifier.activity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;

import com.atlantis.apps.notifier.R;

public class SNMainActivity extends TabActivity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		Button myButton = (Button) findViewById(R.id.exitBtn);
		myButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				moveTaskToBack(true);
				Log.d(getClass().getSimpleName(), "Exiting App");
			}
		});

		Resources res = getResources(); // Resource object to get Drawables
		TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Create an Intent to launch an Activity for the tab (to be reused)
		intent = new Intent().setClass(this, SNCheckNowActivity.class);

		// Initialize a TabSpec for each tab and add it to the TabHost
		spec = tabHost
				.newTabSpec("checknow")
				.setIndicator("Check Now",
						res.getDrawable(R.drawable.ic_menu_checknow))
				.setContent(intent);
		tabHost.addTab(spec);

		// Do the same for the other tabs
		intent = new Intent().setClass(this, SNSettingsActivity.class);
		spec = tabHost
				.newTabSpec("settings")
				.setIndicator("Settings",
						res.getDrawable(R.drawable.ic_menu_settings))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, SNAboutActivity.class);
		spec = tabHost
				.newTabSpec("about")
				.setIndicator("About",
						res.getDrawable(R.drawable.ic_menu_about))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTab(0);
	}
}